var a = getApp();

Page({
    data: {
        schedules: [],
        pageNo: 1,
        total: -1,
        token: ""
    },
    loadData: function() {
        var e = this;
        a.network.post({
            url: a.url.listTeamMemberSchedule,
            params: {
                userAccessToken: e.data.token
            },
            before: function() {
                wx.showNavigationBarLoading();
            },
            success: function(t) {
                if (1 == t.data.result) {
                    var o = t.data.data.schedules;
                    e.setData({
                        schedules: o
                    });
                } else a.util.showToast(t.data.message);
            },
            fail: function() {
                a.util.showToast("获取数据失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading();
            }
        });
    },
    loadHistoryData: function() {
        var e = this, t = e.data.pageNo;
        a.network.post({
            url: a.url.historyListTeamMemberSchedule,
            params: {
                pageNo: t,
                pageSize: 20,
                userAccessToken: e.data.token
            },
            before: function() {
                wx.showNavigationBarLoading();
            },
            success: function(o) {
                if (1 == o.data.result) {
                    var n = e.data.schedules, s = o.data.data.schedules;
                    s.length > 0 ? (n = s.concat(n), t += 1, e.setData({
                        schedules: n,
                        pageNo: t
                    })) : wx.showToast({
                        title: "没有更多历史档期",
                        icon: "none"
                    });
                } else a.util.showToast(o.data.message);
            },
            fail: function() {
                a.util.showToast("获取数据失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
            }
        });
    },
    bindItemClick: function(a) {
        var e = a.currentTarget.dataset.schedule, t = JSON.stringify(e), o = this.data.token == getApp().globalData.accessToken;
        console.log(this.data.token), console.log(getApp().globalData.accessToken);
        var n = o ? "0" : "1";
        wx.navigateTo({
            url: "/pages/schedule/scheduleDetail/scheduleDetail?schedule=" + t + "&hideControl=" + n
        });
    },
    bindPhoneCall: function(a) {
        var e = a.currentTarget.dataset.phone;
        wx.makePhoneCall({
            phoneNumber: e
        });
    },
    onLoad: function(a) {
        this.setData({
            token: a.token
        }), this.loadData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.loadHistoryData();
    },
    onReachBottom: function() {}
});